// ./prisma/seed.ts
import { PrismaClient } from '@prisma/client'

// 直接在种子文件中实现 hashPassword
const hashPassword = async (password: string): Promise<string> => {
  //  const bcrypt = await import('bcryptjs')
   return password
}

const prisma = new PrismaClient()

async function main() {
  console. log('开始种子数据...')
  
   const hashedPassword = await hashPassword('admin123')
  
   await prisma.user.upsert({
    where: { username: 'admin' },
    update: {},
    create: {
      username: 'admin',
      password: hashedPassword,
      email: 'admin@example.com'
    }
  })
  
  console. log('种子数据创建成功!')
}

main()
  . catch((e) => {
    console. error('种子脚本执行错误:', e)
    process. exit(1)
  })
  . finally(async () => {
     await prisma.$disconnect()
  })